package com.probox.common.entity.service.order.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import java.util.Arrays;
import java.util.List;

import com.probox.common.core.utils.DateUtils;
import com.probox.common.core.utils.StringUtils;
import com.probox.common.entity.service.order.IOrderPostSaleNodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.probox.common.entity.mapper.order.OrderPostSaleNodeMapper;
import com.probox.common.entity.domain.order.OrderPostSaleNode;
import org.springframework.transaction.annotation.Transactional;

/**
 * 订单售后节点Service业务层处理
 *
 * @author hds
 * @date 2021-07-12
 */
@Service
@Transactional
public class OrderPostSaleNodeServiceImpl extends ServiceImpl<OrderPostSaleNodeMapper, OrderPostSaleNode> implements IOrderPostSaleNodeService {
    @Autowired
    private OrderPostSaleNodeMapper orderPostSaleNodeMapper;


    /**
     * 查询订单售后节点
     *
     * @param nodeUid 订单售后节点ID
     * @return 订单售后节点
     */
    @Override
    public OrderPostSaleNode selectOrderPostSaleNodeById(Long nodeUid) {
        return this.getById(nodeUid);
    }

    /**
     * 查询订单售后节点列表
     *
     * @param orderPostSaleNode 订单售后节点
     * @return 订单售后节点
     */
    @Override
    public List<OrderPostSaleNode> queryList(OrderPostSaleNode orderPostSaleNode) {
        QueryWrapper<OrderPostSaleNode> queryWrapper = Wrappers.query();
        if (StringUtils.isNotEmpty(String.valueOf(orderPostSaleNode.getNodeUid())) && orderPostSaleNode.getNodeUid() != null) {
            queryWrapper.eq("NODE_UID", orderPostSaleNode.getNodeUid());
        }
        if (StringUtils.isNotEmpty(String.valueOf(orderPostSaleNode.getServiceUid())) && orderPostSaleNode.getServiceUid() != null) {
            queryWrapper.eq("SERVICE_UID", orderPostSaleNode.getServiceUid());
        }
        if (StringUtils.isNotEmpty(String.valueOf(orderPostSaleNode.getNodeStatus())) && orderPostSaleNode.getNodeStatus() != null) {
            queryWrapper.eq("NODE_STATUS", orderPostSaleNode.getNodeStatus());
        }
        if (StringUtils.isNotEmpty(String.valueOf(orderPostSaleNode.getNodeDesc())) && orderPostSaleNode.getNodeDesc() != null) {
            queryWrapper.eq("NODE_DESC", orderPostSaleNode.getNodeDesc());
        }
        if (StringUtils.isNotEmpty(String.valueOf(orderPostSaleNode.getCreateUser())) && orderPostSaleNode.getCreateUser() != null) {
            queryWrapper.eq("CREATE_USER", orderPostSaleNode.getCreateUser());
        }
        if (StringUtils.isNotEmpty(String.valueOf(orderPostSaleNode.getCreateName())) && orderPostSaleNode.getCreateName() != null) {
            queryWrapper.eq("CREATE_NAME", orderPostSaleNode.getCreateName());
        }
        return orderPostSaleNodeMapper.selectList(queryWrapper);
    }

    /**
     * 新增订单售后节点
     *
     * @param orderPostSaleNode 订单售后节点
     * @return 结果
     */
    @Override
    public boolean insertOrderPostSaleNode(OrderPostSaleNode orderPostSaleNode) {

        return this.save(orderPostSaleNode);

    }

    /**
     * 修改订单售后节点
     *
     * @param orderPostSaleNode 订单售后节点
     * @return 结果
     */
    @Override
    public boolean updateOrderPostSaleNode(OrderPostSaleNode orderPostSaleNode) {

        return this.updateById(orderPostSaleNode);
    }

    /**
     * 批量删除订单售后节点
     *
     * @param nodeUids 需要删除的订单售后节点ID
     * @return 结果
     */
    @Override
    public boolean deleteOrderPostSaleNodeByIds(Long[] nodeUids) {
        return this.removeByIds(Arrays.asList(nodeUids));
    }


}
